<template>
  <div class="commonPage">
    <page-template>
      <div slot="title">
        页面标题
      </div>
      <div slot="headerRight">
      </div>
      <div
        slot="content"
        class="content"
      >
        页面内容
      </div>
    </page-template>
  </div>
</template>

<script lang='ts'>
// @ts-ignore
import pageTemplate from '@/components/PageTemplate/index.vue'
import { Component, Vue } from 'vue-property-decorator'
// @ts-ignore
import cheerio from 'cheerio'
import axios from 'axios'
// @ts-ignore
@Component({
  components: {
    pageTemplate
  }
})
export default class Page extends Vue {
  created() {
    this.getData()
    this.getPhotoData()
  }

  async getData() {
    // const axios = require('axios')
    // const cheerio = require('cheerio')
    axios.defaults.baseURL = '/moviesApi'
    const res = await axios.get('/vod/list/n_1/o3p1.html')
    const $ = (cheerio as any).load(res.data)
    const movieList:any = []
    $('.search-list').find('.pic-pack-outer').each(function(index:any, item:any) {
      const url = $(item).attr('href')
      const img = $(item).find('img').attr('src')
      const title = $(item).children().eq(1).text() // .text()会拿到匹配到 下面所有文本
      const score = $(item).children().eq(2).text()
      const msg = $(item).children().eq(3).text()
      if (index !== 0) {
        movieList.push({ url, img, title, score, msg })
      }
      console.log(movieList)
    })
  }

  async getPhotoData() {
    // const axios = require('axios')
    // const cheerio = require('cheerio')
    axios.defaults.baseURL = '/1688Api'
    const res = await axios.get('/page.html?spm=a2638t.b_78128457.szyxdivert.7.3836436c7v2IlG&hpageId=old-sem-pc-list&cosite=baidujj_pz&keywords=%E9%9E%8B%E5%8C%85&trackid=885662561117990122602&location=re&ptid=hr242ba4769b1197&exp=smartHotList:B;zgc_tab:A')
    const $ = (cheerio as any).load(res.data)
    const list:any = []
    $('#offerList').find()
  }
}
</script>

<style lang='scss' scoped>

.commonPage{
  height: 100%;
  .content{
    height: calc(100% - 40px);
  }
}
</style>
